package com.dq.eduservice.controller.front;

import com.dq.commonutils.vo.Result;
import com.dq.eduservice.service.EduCourseService;
import com.dq.eduservice.vo.CourseVo;
import com.dq.eduservice.vo.FrontCourseVo;
import com.dq.eduservice.vo.param.front.CourseFrontParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @project: guli_parent
 * @ClassName: CourseFrontController
 * @author: dq
 * @creat: 2022/8/13 12:35
 */
@RestController
@RequestMapping("eduservice/coursefront")
@CrossOrigin
public class CourseFrontController {

    @Autowired
    private EduCourseService courseService;

    /**
     * 根据条件查询课程
     * @param courseFrontParam
     * @return
     */
    @PostMapping("getCourseFrontList")
    public Result getCourseFrontList(@RequestBody CourseFrontParam courseFrontParam){
        Map<String,Object> map = courseService.getCourseFrontList(courseFrontParam);
        return Result.success(map);
    }

    /**
     * 获取课程具体信息
     * 手写sql
     * @param courseId
     * @return CourseInfo
     */
    @GetMapping("getCourseDetailInfo/{id}")
    public Result getFinalCourseDetailInfo(@PathVariable("id") String courseId){
        FrontCourseVo courseVo =courseService.getFinalCourseDetailInfo(courseId);
        return Result.success(courseVo);
    }

}
